#pragma once


CARBON_NS_BEGIN

template<class Iter>
struct RevIterator {
    using NodeType = typename Iter::NodeType;
    using ValueType = typename Iter::ValueType;

    Iter   m_iter;

    RevIterator() {}
    RevIterator(Iter iter) : m_iter(iter) {}

    ValueType & operator*() const   { return *m_iter; }
    ValueType * operator->() const  { return m_iter.operator->(); }

    RevIterator & operator++()   { --m_iter; return *this; }
    RevIterator & operator--()   { ++m_iter; return *this; }
    RevIterator operator++(int) const   { auto tmp = *this; --m_iter; return tmp;  }
    RevIterator operator--(int) const   { auto tmp = *this; ++m_iter; return tmp;  }

    bool operator==(const RevIterator & other) const { return m_iter == other.m_other; }
    bool operator!=(const RevIterator & other) const { return m_iter != other.m_other; }
};

CARBON_NS_END
